
layui.use(['layer','echarts','jquery'],function() {
		var $ = layui.jquery;
		let echarts = layui.echarts;
		var column2 = echarts.init(document.getElementById('echarts-records2'),null, {
			width: 900,
			height: 400
		});
		column2.showLoading();

		var yesOrder = [];
		var NoOrder  = [];
		var cityList = [];
		$.ajax({
			type: "post",
			url: "/orders/getCityOrderList",
			data:{},
			dataType : 'json',
			success:function (data) {
				if(data){
					for (var i = 0; i < data.length; i++) {
						yesOrder.push(data[i].dealYes);
						NoOrder.push(data[i].dealNo);
						cityList.push(data[i].cityName);
					}
					console.log(yesOrder);
					column2.hideLoading();
					column2.setOption({
						backgroundColor: '#ffffff',
						title: {
							text: '热门城市门店订单对比',
							left: 'center',
							top: 2,
							fontSize: 20
						},
						color: ['#fed46b','#2194ff', ],
						tooltip: {
							trigger: 'axis',
							axisPointer: { // 坐标轴指示器，坐标轴触发有效
								type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
							}
						},
						grid: {
							left: '3%',
							right: '4%',
							bottom: '10%',
							containLabel: true
						},
						legend: {
							left: 'center',
							bottom: '2%',
							data: ['已成交', '退订', ]
						},
						xAxis: [{
							type: 'category',
							data: cityList,
							axisTick: {
								alignWithLabel: true
							},axisLabel: {
								margin: 20,
								fontSize: 14,
								color: 'rgba(#999)'
							}
						}],
						yAxis: [{
							type: 'value',
						}],
						barMaxWidth: '30',
						label:{
							show:true,
							position:'top',
							formatter:function(params){
								return params.value
							}
						},
						series: [
							{
								name: '已成交',
								type: 'bar',
								data: yesOrder
							},
							{
								name: '退订',
								type: 'bar',
								data: NoOrder
							},
						]
					})
				}
			},error:function () {
				layer.msg("图表请求失败");
				// column2.hideLoading();
			}
		});
	});




